package com.easy.controller;

import com.easy.bean.User;
import com.easy.service.IShoppingLoginService;
import com.easy.util.SYS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("shopping")
public class ShoppingLoginController {
    @Autowired
    IShoppingLoginService shoppingLoginService;
    @RequestMapping("dologin")
    @ResponseBody
    public String shoppingLogin(User user, HttpSession session){
        //执行登录业务
        User u= shoppingLoginService.dologin(user);
        if(u!=null){
            //记录登陆状态
            session.setAttribute(SYS.SHOPPING_LOGIN_USER,u);
            return "success";
        }else{
            return "fail";
        }
    }
}
